package com.huarui.donation.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.ewaf.framework.action.BaseAction;
import org.ewaf.framework.model.ListModel;
import org.ewaf.framework.model.PagingInfo;

import com.huarui.desktop.model.TableMetaData;
import com.huarui.desktop.service.TableMetaDataService;
import com.huarui.desktop.service.TableRecordDataService;
import com.huarui.donation.service.DonationService;
import com.huarui.initial.util.InitialUtil;
import com.opensymphony.xwork2.Action;

public class DonationAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private Integer start=0;
	private Integer limit=10;
	private String keyword;
	private ListModel listModel=new ListModel();
	private DonationService donationService;
	private Map<String,Object> resultMap=new HashMap<String,Object>();
	public String extList() {
		listModel.setPageSize(limit == null ? 10 : limit);
		listModel.setPage(start == null ? 0 : start / limit + 1);
		Map<String,Object> map=new HashMap<String, Object>();
		if(keyword!=null){
			List<String> conditions = new ArrayList<String>();
			InitialUtil.addToCollection(conditions, InitialUtil.split(keyword, " ,"));
			map.put("conditions",conditions);
		}
		donationService.pagingByCondition(listModel, map);
		resultMap.put("totalProperty", listModel.getTotal());
		resultMap.put("root", listModel.getResult());
		return Action.SUCCESS;
	}
	public Map<String, Object> getResultMap() {
		return resultMap;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
	public void setDonationService(DonationService donationService) {
		this.donationService = donationService;
	}
	public void setStart(Integer start) {
		this.start = start;
	}
	public void setLimit(Integer limit) {
		this.limit = limit;
	}
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	public void setListModel(ListModel listModel) {
		this.listModel = listModel;
	}
	

}
